package com.liao.service.impl;

import com.liao.bean.Code;
import com.liao.dao.CodeDao;
import com.liao.service.CodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class CodeServiceImpl implements CodeService {

    @Autowired
    private CodeDao codeDao;


    @Override
    public void operateCode(String phoneNum, String code) throws Exception {
        //根据phoneNum查询是否有记录
        Code inputCode = new Code(null,phoneNum,code);
        Code existCode=codeDao.selectCodeByPhoneNum(phoneNum);
        if(null == existCode){
            //添加Code
            codeDao.insertCode(inputCode);
        }else {
            //修改
            codeDao.updateCode(inputCode);
        }
    }
}
